From ab55ca22598c286aeb5be2cbc7538216343da4df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 01:08:35 +0000 Subject: [PATCH 001/146] Auto-generated commit 853a91bd6a2d10345bb166ea7597c7bba39648d1 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 1550 ++++++++++++++++++++++++++++ index.d.ts | 26 + index.mjs | 4 + index.mjs.map | 1 + package.json | 39 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 4819 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..7e81ab5 --- /dev/null +++ b/README.md @@ -0,0 +1,1550 @@ + + +# Uint16Array + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 16-bit unsigned integers in the platform byte order. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` + +#### Uint16Array() + +A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 16-bit unsigned integers in the platform byte order. + + + +```javascript +var arr = new Uint16Array(); +// returns +``` + +#### Uint16Array( length ) + +Returns a [typed array][mdn-typed-array] having a specified length. + + + +```javascript +var arr = new Uint16Array( 5 ); +// returns [ 0, 0, 0, 0, 0 ] +``` + +#### Uint16Array( typedarray ) + +Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. + + + +```javascript +import Float32Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float32@esm/index.mjs'; + +var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); +var arr2 = new Uint16Array( arr1 ); +// returns [ 5, 5, 5 ] +``` + +#### Uint16Array( obj ) + +Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. + + + +```javascript +var arr = new Uint16Array( [ 5.0, 5.0, 5.0 ] ); +// returns [ 5, 5, 5 ] +``` + +#### Uint16Array( buffer\[, byteOffset\[, length]] ) + +Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + + + +```javascript +import ArrayBuffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs'; + +var buf = new ArrayBuffer( 8 ); +var arr = new Uint16Array( buf, 0, 4 ); +// returns [ 0, 0, 0, 0 ] +``` + +* * * + +### Properties + + + +#### Uint16Array.BYTES_PER_ELEMENT + +Number of bytes per view element. + + + +```javascript +var nbytes = Uint16Array.BYTES_PER_ELEMENT; +// returns 2 +``` + + + +#### Uint16Array.name + +[Typed array][mdn-typed-array] constructor name. + + + +```javascript +var str = Uint16Array.name; +// returns 'Uint16Array' +``` + + + +#### Uint16Array.prototype.buffer + +**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. + + + +```javascript +var arr = new Uint16Array( 5 ); +var buf = arr.buffer; +// returns +``` + + + +#### Uint16Array.prototype.byteLength + +**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. + + + +```javascript +var arr = new Uint16Array( 5 ); +var byteLength = arr.byteLength; +// returns 10 +``` + + + +#### Uint16Array.prototype.byteOffset + +**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. + + + +```javascript +var arr = new Uint16Array( 5 ); +var byteOffset = arr.byteOffset; +// returns 0 +``` + + + +#### Uint16Array.prototype.BYTES_PER_ELEMENT + +Number of bytes per view element. + + + +```javascript +var arr = new Uint16Array( 5 ); +var nbytes = arr.BYTES_PER_ELEMENT; +// returns 2 +``` + + + +#### Uint16Array.prototype.length + +**Read-only** property which returns the number of view elements. + + + +```javascript +var arr = new Uint16Array( 5 ); +var len = arr.length; +// returns 5 +``` + +* * * + +### Methods + + + +#### Uint16Array.from( src\[, map\[, thisArg]] ) + +Creates a new typed array from an array-like `object` or an iterable. + +```javascript +var arr = Uint16Array.from( [ 1, 2 ] ); +// returns [ 1, 2 ] +``` + +To invoke a function for each `src` value, provide a callback function. + +```javascript +function mapFcn( v ) { + return v * 2; +} + +var arr = Uint16Array.from( [ 1, 2 ], mapFcn ); +// returns [ 2, 4 ] +``` + +A callback function is provided two arguments: + +- `value`: source value +- `index`: source index + +To set the callback execution context, provide a `thisArg`. + +```javascript +function mapFcn( v ) { + this.count += 1; + return v * 2; +} + +var ctx = { + 'count': 0 +}; + +var arr = Uint16Array.from( [ 1, 2 ], mapFcn, ctx ); +// returns [ 2, 4 ] + +var n = ctx.count; +// returns 2 +``` + + + +#### Uint16Array.of( element0\[, element1\[, ...elementN]] ) + +Creates a new typed array from a variable number of arguments. + +```javascript +var arr = Uint16Array.of( 1, 2 ); +// returns [ 1, 2 ] +``` + + + +#### Uint16Array.prototype.copyWithin( target, start\[, end] ) + +Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); + +// Copy the last two elements to the first two elements: +arr.copyWithin( 0, 3 ); + +var v = arr[ 0 ]; +// returns 4 + +v = arr[ 1 ]; +// returns 5 +``` + +By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); + +// Copy the first two elements to the last two elements: +arr.copyWithin( 3, 0, 2 ); + +var v = arr[ 3 ]; +// returns 1 + +v = arr[ 4 ]; +// returns 2 +``` + +When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); + +// Copy the first two elements to the last two elements: +arr.copyWithin( -2, -5, -3 ); + +var v = arr[ 3 ]; +// returns 1 + +v = arr[ 4 ]; +// returns 2 +``` + + + +#### Uint16Array.prototype.entries() + +Returns an iterator for iterating over array key-value pairs. + + + +```javascript +var arr = new Uint16Array( [ 1, 2 ] ); + +// Create an iterator: +var it = arr.entries(); + +// Iterate over key-value pairs... +var v = it.next().value; +// returns [ 0, 1 ] + +v = it.next().value; +// returns [ 1, 2 ] + +var bool = it.next().done; +// returns true +``` + + + +#### Uint16Array.prototype.every( predicate\[, thisArg] ) + +Tests whether all array elements pass a test implemented by a `predicate` function. + + + +```javascript +function predicate( v ) { + return ( v <= 1 ); +} + +var arr = new Uint16Array( [ 1, 2 ] ); + +var bool = arr.every( predicate ); +// returns false +``` + +A `predicate` function is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function predicate( v ) { + this.count += 1; + return ( v >= 1 ); +} + +var ctx = { + 'count': 0 +}; + +var arr = new Uint16Array( [ 1, 2 ] ); + +var bool = arr.every( predicate, ctx ); +// returns true + +var n = ctx.count; +// returns 2 +``` + + + +#### Uint16Array.prototype.fill( value\[, start\[, end]] ) + +Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. + + + +```javascript +var arr = new Uint16Array( 2 ); + +// Set all array elements to the same value: +arr.fill( 2 ); + +var v = arr[ 0 ]; +// returns 2 + +v = arr[ 1 ]; +// returns 2 + +// Set all array elements starting from the first index to the same value: +arr.fill( 3, 1 ); + +v = arr[ 0 ]; +// returns 2 + +v = arr[ 1 ]; +// returns 3 + +// Set all array elements, except the last element, to the same value: +arr.fill( 4, 0, arr.length-1 ); + +v = arr[ 0 ]; +// returns 4 + +v = arr[ 1 ]; +// returns 3 +``` + +When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. + + + +```javascript +var arr = new Uint16Array( 2 ); + +// Set all array elements, except the last element, to the same value: +arr.fill( 2, -arr.length, -1 ); + +var v = arr[ 0 ]; +// returns 2 + +v = arr[ 1 ]; +// returns 0 +``` + + + +#### Uint16Array.prototype.filter( predicate\[, thisArg] ) + +Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. + + + +```javascript +function predicate( v ) { + return ( v >= 2 ); +} + +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.filter( predicate ); +// returns [ 2, 3 ] +``` + +If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. + + + +```javascript +function predicate( v ) { + return ( v >= 10 ); +} + +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.filter( predicate ); +// returns [] +``` + +A `predicate` function is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function predicate( v ) { + this.count += 1; + return ( v >= 2 ); +} + +var ctx = { + 'count': 0 +}; + +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.filter( predicate, ctx ); + +var n = ctx.count; +// returns 3 +``` + + + +#### Uint16Array.prototype.find( predicate\[, thisArg] ) + +Returns the first array element for which a provided `predicate` function returns a truthy value. + + + +```javascript +function predicate( v ) { + return ( v > 2 ); +} + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var v = arr.find( predicate ); +// returns 3 +``` + +If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. + + + +```javascript +function predicate( v ) { + return ( v < 1 ); +} + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var v = arr.find( predicate ); +// returns undefined +``` + +A `predicate` function is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function predicate( v ) { + this.count += 1; + return ( v > 2 ); +} + +var ctx = { + 'count': 0 +}; + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var v = arr.find( predicate, ctx ); +// returns 3 + +var n = ctx.count; +// returns 3 +``` + + + +#### Uint16Array.prototype.findIndex( predicate\[, thisArg] ) + +Returns the index of the first array element for which a provided `predicate` function returns a truthy value. + + + +```javascript +function predicate( v ) { + return ( v >= 3 ); +} + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.findIndex( predicate ); +// returns 2 +``` + +If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. + + + +```javascript +function predicate( v ) { + return ( v < 1 ); +} + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.findIndex( predicate ); +// returns -1 +``` + +A `predicate` function is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function predicate( v ) { + this.count += 1; + return ( v >= 3 ); +} + +var ctx = { + 'count': 0 +}; + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.findIndex( predicate, ctx ); +// returns 2 + +var n = ctx.count; +// returns 3 +``` + + + +#### Uint16Array.prototype.forEach( fcn\[, thisArg] ) + +Invokes a callback for each array element. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var str = ''; + +function fcn( v, i ) { + str += i + ':' + v; + if ( i < arr.length-1 ) { + str += ' '; + } +} + +arr.forEach( fcn ); + +console.log( str ); +// => '0:1 1:2 2:3' +``` + +The callback is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function fcn() { + this.count += 1; +} + +var ctx = { + 'count': 0 +}; + +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +arr.forEach( fcn, ctx ); + +var n = ctx.count; +// returns 3 +``` + + + +#### Uint16Array.prototype.includes( searchElement\[, fromIndex] ) + +Returns a `boolean` indicating whether an array includes a search element. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var bool = arr.includes( 3 ); +// returns true + +bool = arr.includes( 0 ); +// returns false +``` + +By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var bool = arr.includes( 1, 1 ); +// returns false +``` + +When a `fromIndex` is negative, the starting index is resolved relative to the last array element. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +bool = arr.includes( 1, -2 ); +// returns false +``` + + + +#### Uint16Array.prototype.indexOf( searchElement\[, fromIndex] ) + +Returns the index of the first array element strictly equal to a search element. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.indexOf( 3 ); +// returns 2 + +idx = arr.indexOf( 0 ); +// returns -1 +``` + +By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.indexOf( 1, 1 ); +// returns -1 +``` + +When a `fromIndex` is negative, the starting index is resolved relative to the last array element. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var idx = arr.indexOf( 1, -2 ); +// returns -1 +``` + + + +#### Uint16Array.prototype.join( \[separator] ) + +Serializes an array by joining all array elements as a string. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var str = arr.join(); +// returns '1,2,3' +``` + +By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var str = arr.join( '|' ); +// returns '1|2|3' +``` + + + +#### Uint16Array.prototype.keys() + +Returns an iterator for iterating over array keys. + + + +```javascript +var arr = new Uint16Array( [ 1, 2 ] ); + +// Create an iterator: +var it = arr.keys(); + +// Iterate over keys... +var v = it.next().value; +// returns 0 + +v = it.next().value; +// returns 1 + +var bool = it.next().done; +// returns true +``` + + + +#### Uint16Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) + +Returns the index of the last array element strictly equal to a search element, iterating from right to left. + + + +```javascript +var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); + +var idx = arr.lastIndexOf( 0 ); +// returns 3 + +idx = arr.lastIndexOf( 3 ); +// returns -1 +``` + +By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. + + + +```javascript +var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); + +var idx = arr.lastIndexOf( 0, 2 ); +// returns 1 +``` + +When a `fromIndex` is negative, the starting index is resolved relative to the last array element. + + + +```javascript +var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); + +var idx = arr.lastIndexOf( 0, -3 ); +// returns 1 +``` + + + +#### Uint16Array.prototype.map( fcn\[, thisArg] ) + +Maps each array element to an element in a new array having the same data type as the host array. + + + +```javascript +function fcn( v ) { + return v * 2; +} + +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.map( fcn ); +// returns [ 2, 4, 6 ] +``` + +A callback is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function fcn( v ) { + this.count += 1; + return v * 2; +} + +var ctx = { + 'count': 0 +}; + +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.map( fcn, ctx ); + +var n = ctx.count; +// returns 3 +``` + + + +#### Uint16Array.prototype.reduce( fcn\[, initialValue] ) + +Applies a function against an accumulator and each element in an array and returns the accumulated result. + + + +```javascript +function fcn( acc, v ) { + return acc + ( v*v ); +} + +var arr = new Uint16Array( [ 2, 1, 3 ] ); + +var v = arr.reduce( fcn ); +// returns 12 +``` + +If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. + +If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. + + + +```javascript +function fcn( acc, v ) { + return acc + ( v*v ); +} + +var arr = new Uint16Array( [ 2, 1, 3 ] ); + +var v = arr.reduce( fcn, 0 ); +// returns 14 +``` + +A callback is provided four arguments: + +- `acc`: accumulated result +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + + + +#### Uint16Array.prototype.reduceRight( fcn\[, initialValue] ) + +Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. + + + +```javascript +function fcn( acc, v ) { + return acc + ( v*v ); +} + +var arr = new Uint16Array( [ 2, 1, 3 ] ); + +var v = arr.reduceRight( fcn ); +// returns 8 +``` + +If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. + +If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. + + + +```javascript +function fcn( acc, v ) { + return acc + ( v*v ); +} + +var arr = new Uint16Array( [ 2, 1, 3 ] ); + +var v = arr.reduce( fcn, 0 ); +// returns 14 +``` + +A callback is provided four arguments: + +- `acc`: accumulated result +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + + + +#### Uint16Array.prototype.reverse() + +Reverses an array **in-place** (thus mutating the array on which the method is invoked). + + + +```javascript +var arr = new Uint16Array( [ 2, 0, 3 ] ); + +// Reverse the array: +arr.reverse(); + +var v = arr[ 0 ]; +// returns 3 + +v = arr[ 1 ]; +// returns 0 + +v = arr[ 2 ]; +// returns 2 +``` + + + +#### Uint16Array.prototype.set( arr\[, offset] ) + +Sets array elements. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); +// returns [ 1, 2, 3 ] + +// Set the first two array elements: +arr.set( [ 4, 5 ] ); + +var v = arr[ 0 ]; +// returns 4 + +v = arr[ 1 ]; +// returns 5 +``` + +By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); +// returns [ 1, 2, 3 ] + +// Set the last two array elements: +arr.set( [ 4, 5 ], 1 ); + +var v = arr[ 1 ]; +// returns 4 + +v = arr[ 2 ]; +// returns 5 +``` + + + +#### Uint16Array.prototype.slice( \[begin\[, end]] ) + +Copies array elements to a new array with the same underlying data type as the host array. + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.slice(); + +var bool = ( arr1 === arr2 ); +// returns false + +bool = ( arr1.buffer === arr2.buffer ); +// returns false + +var v = arr2[ 0 ]; +// returns 1 + +v = arr2[ 1 ]; +// returns 2 + +v = arr2[ 2 ]; +// returns 3 +``` + +By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.slice( 1 ); + +var len = arr2.length; +// returns 2 + +var v = arr2[ 0 ]; +// returns 2 + +v = arr2[ 1 ]; +// returns 3 +``` + +By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.slice( 0, 2 ); + +var len = arr2.length; +// returns 2 + +var v = arr2[ 0 ]; +// returns 1 + +v = arr2[ 1 ]; +// returns 2 +``` + +When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.slice( -arr1.length, -1 ); + +var len = arr2.length; +// returns 2 + +var v = arr2[ 0 ]; +// returns 1 + +v = arr2[ 1 ]; +// returns 2 +``` + + + +#### Uint16Array.prototype.some( predicate\[, thisArg] ) + +Tests whether at least one array element passes a test implemented by a `predicate` function. + + + +```javascript +function predicate( v ) { + return ( v >= 2 ); +} + +var arr = new Uint16Array( [ 1, 2 ] ); + +var bool = arr.some( predicate ); +// returns true +``` + +A `predicate` function is provided three arguments: + +- `value`: array element +- `index`: array index +- `arr`: array on which the method is invoked + +To set the callback execution context, provide a `thisArg`. + + + +```javascript +function predicate( v ) { + this.count += 1; + return ( v >= 2 ); +} + +var ctx = { + 'count': 0 +}; + +var arr = new Uint16Array( [ 1, 1 ] ); + +var bool = arr.some( predicate, ctx ); +// returns false + +var n = ctx.count; +// returns 2 +``` + + + +#### Uint16Array.prototype.sort( \[compareFunction] ) + +Sorts an array **in-place** (thus mutating the array on which the method is invoked). + + + +```javascript +var arr = new Uint16Array( [ 2, 3, 0 ] ); + +// Sort the array (in ascending order): +arr.sort(); + +var v = arr[ 0 ]; +// returns 0 + +v = arr[ 1 ]; +// returns 2 + +v = arr[ 2 ]; +// returns 3 +``` + +By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. + + + +```javascript +function descending( a, b ) { + return b - a; +} + +var arr = new Uint16Array( [ 2, 3, 0 ] ); + +// Sort the array (in descending order): +arr.sort( descending ); + +var v = arr[ 0 ]; +// returns 3 + +v = arr[ 1 ]; +// returns 2 + +v = arr[ 2 ]; +// returns 0 +``` + +The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: + +- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). +- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). +- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. + + + +#### Uint16Array.prototype.subarray( \[begin\[, end]] ) + +Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.subarray(); +// returns [ 1, 2, 3 ] + +var bool = ( arr1.buffer === arr2.buffer ); +// returns true +``` + +By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.subarray( 1 ); +// returns [ 2, 3 ] + +var bool = ( arr1.buffer === arr2.buffer ); +// returns true +``` + +By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.subarray( 0, 2 ); +// returns [ 1, 2 ] + +var bool = ( arr1.buffer === arr2.buffer ); +// returns true +``` + +When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.subarray( -arr1.length, -1 ); +// returns [ 1, 2 ] + +var bool = ( arr1.buffer === arr2.buffer ); +// returns true +``` + +If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. + + + +```javascript +var arr1 = new Uint16Array( [ 1, 2, 3 ] ); + +var arr2 = arr1.subarray( 10, -1 ); +// returns [] +``` + + + +#### Uint16Array.prototype.toLocaleString( \[locales\[, options]] ) + +Serializes an array as a locale-specific `string`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var str = arr.toLocaleString(); +// returns '1,2,3' +``` + + + +#### Uint16Array.prototype.toString() + +Serializes an array as a `string`. + + + +```javascript +var arr = new Uint16Array( [ 1, 2, 3 ] ); + +var str = arr.toString(); +// returns '1,2,3' +``` + + + +#### Uint16Array.prototype.values() + +Returns an iterator for iterating over array elements. + + + +```javascript +var arr = new Uint16Array( [ 1, 2 ] ); + +// Create an iterator: +var it = arr.values(); + +// Iterate over array elements... +var v = it.next().value; +// returns 1 + +v = it.next().value; +// returns 2 + +var bool = it.next().done; +// returns true +``` + +
+ + + +* * * + + + +
+ +
+ + + + + +
+ +## 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..c6081c4 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,26 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +// EXPORTS // + +/** +* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. +*/ +export = Uint16Array; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a4a3338 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";var r="function"==typeof Uint16Array?Uint16Array:void 0,n=function(){throw new Error("not implemented")},e=t()?r:n;export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..daef837 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill.js","../lib/index.js","../lib/uint16array.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// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './uint16array.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"],"names":["builtin","Uint16Array","polyfill","Error","lib","require$$0"],"mappings":";;kGAoCA,ICDIA,ECbgC,mBAAhBC,YAA+BA,iBAAc,EDc7DC,EDPJ,WACC,MAAM,IAAIC,MAAO,oBCqBlBC,EAjB4BC,IASpBL,EAEAE"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..d7bea62 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "@stdlib/array-uint16", + "version": "0.0.0", + "description": "Uint16Array.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-uint16.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "array", + "typed", + "typed array", + "typed-array", + "uint16array", + "uint16", + "uint16_t", + "integer", + "int", + "uint", + "unsigned", + "short" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..272acbe --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From a42dc7286032956a57d0140f3fd78ca89918f838 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:56:21 +0000 Subject: [PATCH 002/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 32036974e000845ae19f4392533807a8cd1f0766 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 11:30:52 +0000 Subject: [PATCH 003/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a4a3338..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";var r="function"==typeof Uint16Array?Uint16Array:void 0,n=function(){throw new Error("not implemented")},e=t()?r:n;export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index daef837..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill.js","../lib/index.js","../lib/uint16array.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// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './uint16array.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"],"names":["builtin","Uint16Array","polyfill","Error","lib","require$$0"],"mappings":";;kGAoCA,ICDIA,ECbgC,mBAAhBC,YAA+BA,iBAAc,EDc7DC,EDPJ,WACC,MAAM,IAAIC,MAAO,oBCqBlBC,EAjB4BC,IASpBL,EAEAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 272acbe..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1db709ef66d420fa923eebfdbc6d7cb5a93823f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 11:31:36 +0000 Subject: [PATCH 004/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/polyfill.js | 39 - lib/uint16array.js | 28 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 2723 insertions(+), 9036 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/polyfill.js delete mode 100644 lib/uint16array.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 fb1da3c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:39:17.491Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..224519e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c0d95d9 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ff54c1a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './uint16array.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/lib/uint16array.js b/lib/uint16array.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/uint16array.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..764b711 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 32c7a91..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './uint16array.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 903b0d7c62f9d468e4f3da4415d420bc0b976875 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:28:02 +0000 Subject: [PATCH 005/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From cab79c8bfde9083a35447239684768bf0653049c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 07:35:06 +0000 Subject: [PATCH 006/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 224519e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c0d95d9..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 764b711..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 53ba37dde7bdf136cddfe8a70afa8b982a6858f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 07:36:05 +0000 Subject: [PATCH 007/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/polyfill.js | 39 - lib/uint16array.js | 28 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 2723 insertions(+), 9036 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/polyfill.js delete mode 100644 lib/uint16array.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 99b7eed..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:54:30.067Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..224519e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c0d95d9 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ff54c1a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './uint16array.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/lib/uint16array.js b/lib/uint16array.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/uint16array.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d20a7ea --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 32c7a91..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './uint16array.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 7d0d23ed394201984daffffcbcfc469b091f07c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:36:34 +0000 Subject: [PATCH 008/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 2ec81a37577fe9bebc9d3a63412c3f44be253448 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:10:50 +0000 Subject: [PATCH 009/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 224519e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c0d95d9..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d20a7ea..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 23496e105dd742f0b7ce497476f080345b963fd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:12:03 +0000 Subject: [PATCH 010/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/polyfill.js | 39 - lib/uint16array.js | 28 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 91 files changed, 2723 insertions(+), 9001 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/polyfill.js delete mode 100644 lib/uint16array.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..224519e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c0d95d9 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ff54c1a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './uint16array.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/lib/uint16array.js b/lib/uint16array.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/uint16array.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c6c3c99 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 32c7a91..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './uint16array.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From efa836a2e35023afdd226af79ea27205079ce1ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:51:23 +0000 Subject: [PATCH 011/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0cb1c57d8ebc57c14829dd60a676e1b233d6b40b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:28:20 +0000 Subject: [PATCH 012/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 224519e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c0d95d9..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c6c3c99..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 5affb59f291a7459781c5bc9cb57e84c86671c89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:29:13 +0000 Subject: [PATCH 013/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/polyfill.js | 39 - lib/uint16array.js | 28 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 2723 insertions(+), 9075 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/polyfill.js delete mode 100644 lib/uint16array.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 412ae8b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:57:39.178Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..677d595 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ff54c1a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './uint16array.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/lib/uint16array.js b/lib/uint16array.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/uint16array.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..28b3cb8 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 32c7a91..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './uint16array.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 9f3c9148971e1a2f911d8e32d5abd7cfa72d1d60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:23:36 +0000 Subject: [PATCH 014/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From feb8d03c82f1d0fbb707ecb8636d5a2dbc36f4f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:25:15 +0000 Subject: [PATCH 015/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 677d595..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 28b3cb8..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b981b41f4f5162811de4b38b019699715c0c5302 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:26:13 +0000 Subject: [PATCH 016/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/polyfill.js | 39 - lib/uint16array.js | 28 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 2723 insertions(+), 9091 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/polyfill.js delete mode 100644 lib/uint16array.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 456656a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:54:06.989Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..677d595 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index ff54c1a..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './uint16array.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/lib/uint16array.js b/lib/uint16array.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/uint16array.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..53e0990 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 32c7a91..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './uint16array.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From f70a48a05785de76a1c30ba2e40b317174026f1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 18:01:18 +0000 Subject: [PATCH 017/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ce15d539a9694d10bf02d84ca7f693463a90df7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 18:09:16 +0000 Subject: [PATCH 018/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 677d595..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/uint16array.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './uint16array.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 53e0990..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From eb379727934293e5c06b7f67c899dbd196e38c2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 18:10:24 +0000 Subject: [PATCH 019/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 91 files changed, 2723 insertions(+), 9090 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..66558df --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..beb113a --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 3c6a9a6c0ceea166e6143dc93dfbccb47d307b43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:43:22 +0000 Subject: [PATCH 020/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 151092edab018bc6fead9414ccbb8aa6926e4fa2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:54:55 +0000 Subject: [PATCH 021/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 66558df..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index beb113a..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From fbccd3b04f49da57c15d5baf3a26a347a2562f5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:56:05 +0000 Subject: [PATCH 022/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 -- benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ------ docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 2689 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 2723 insertions(+), 9091 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 4ebc984..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:18:56.784Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..66558df --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..798bd02 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 783ea0643a1b2c4bdcf467383844520d8a3055c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:20:42 +0000 Subject: [PATCH 023/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3a7d6d79666426da5afebcfe5193dd689bc63415 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:48:27 +0000 Subject: [PATCH 024/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2720 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 66558df..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 798bd02..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 770b8af748ac12c2175f5a7d2727b78f3b758225 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:49:53 +0000 Subject: [PATCH 025/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ---- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 4044 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 4078 insertions(+), 9091 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 2719bff..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:07:16.578Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f6d7d33 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f629871 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 5444b813c53c8a74022f00291f2cd9b184dc809f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:51:28 +0000 Subject: [PATCH 026/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 9ffe458..845cf47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From fccd5388fb6d690a8e1ca4237bc4264fdb42b29e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:09:18 +0000 Subject: [PATCH 027/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4075 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f6d7d33..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f629871..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b9d99003873656e17df831f38a4b549a67ccd145 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:10:07 +0000 Subject: [PATCH 028/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ---- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 4044 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 4078 insertions(+), 9112 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 053ea2a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:28:34.680Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f6d7d33 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 845cf47..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2fc5dde --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From c127a916b068526142253ba3ee3e9fda63dcc3ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:38:46 +0000 Subject: [PATCH 029/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 874e5ab..aa0c82d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 809d99b02f065044c8bb7a5bdb3f55d6d223497a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 10:53:50 +0000 Subject: [PATCH 030/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4075 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f6d7d33..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16' ;\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2fc5dde..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4347c86e24b6ff798ddcae0a68c2313328ba1bc5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 10:54:37 +0000 Subject: [PATCH 031/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ---- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 4044 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 4078 insertions(+), 9117 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 e7b0345..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:18:55.302Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e5cafad --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index aa0c82d..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4ac5f61 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From a311f0f807f485e8331ddf803968c93438e76c70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:30:37 +0000 Subject: [PATCH 032/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index cbf987d..d1fc0ab 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From c5dfce43f14ef487cad4e57d08ce8a7494cc0e02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 11:18:28 +0000 Subject: [PATCH 033/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4075 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e5cafad..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4ac5f61..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 87f6b8a6cd366d2f2e523612e537534b75e77099 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 11:19:15 +0000 Subject: [PATCH 034/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 ---- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 4044 +++++++++++++++++ test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 4078 insertions(+), 9128 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 2200cd9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:57:36.080Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index d1fc0ab..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5560d8c --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 0961abf2fcf592eef9b3d3fbc4c496274de49d6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:38:48 +0000 Subject: [PATCH 035/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index cbf987d..d1fc0ab 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x" + "@stdlib/assert-has-uint16array-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.x", @@ -95,4 +96,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From d1eea2d6f4704d74528ab78552f3711015297c2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:35:06 +0000 Subject: [PATCH 036/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4075 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5560d8c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e765c2e4c0bbfc1e33175eec3c8134be2d555e66 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:36:00 +0000 Subject: [PATCH 037/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9128 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 432958c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:13:26.531Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index d4b836c..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/array/uint16" -click B href "https://github.com/stdlib-js/array-uint16/tree/main" -click C href "https://github.com/stdlib-js/array-uint16/tree/production" -click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index d1fc0ab..a6e84a5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-is-arraybuffer": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/math-base-special-round": "^0.0.x", - "@stdlib/random-base-randi": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8057cb4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 91aec0212463243c03ec0d7314d2043457bb0313 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 03:47:46 +0000 Subject: [PATCH 038/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 998d35f033ffdf4e963d023ed7286fb2d0e0d800 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 08:59:03 +0000 Subject: [PATCH 039/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8057cb4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1631520def57a513586edd4430252fd26b3396e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 08:59:43 +0000 Subject: [PATCH 040/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9263 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 9f1d6e1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T02:27:46.856Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8565c5d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 1b44b46273ea7a35a9e95a326e22b0ccfbb44809 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 04:08:08 +0000 Subject: [PATCH 041/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bda9d2244c2b855eb16b56c636be4e384cbab8fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 08:51:52 +0000 Subject: [PATCH 042/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8565c5d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6d62e8a32ba0ae84c48e5d952414774ad7ba382e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 08:53:00 +0000 Subject: [PATCH 043/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9269 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 09c51c0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T02:45:04.976Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b23b15c --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 16b757cbeb27f6aa8e2edf900b640b736849ed25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 03:57:20 +0000 Subject: [PATCH 044/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 29306e9b59ea8e2c2d59d466e97756be4e881d7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 08:39:15 +0000 Subject: [PATCH 045/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b23b15c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b94398f3971744cf52c17a0c65696c43912fbf57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 08:40:09 +0000 Subject: [PATCH 046/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9269 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 4b82824..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T02:38:44.696Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..352f324 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 6520a03a0824819e751fc4ce5dd3d91f86040bf2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 03:48:28 +0000 Subject: [PATCH 047/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 237206aae347ec60fdc365706bb2b3c79becae57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 09:02:57 +0000 Subject: [PATCH 048/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 352f324..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b541abf67d0d682d4e1ddcb1353d6ad25ec90fd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 09:03:45 +0000 Subject: [PATCH 049/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9269 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 44977c4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T02:29:25.081Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d56a3c1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 337749f729991d1cc6d538a7e04aaaf6ee5aaf3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 03:50:51 +0000 Subject: [PATCH 050/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 14283f7784de79a51032b25706e412c732186b26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 08:51:27 +0000 Subject: [PATCH 051/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d56a3c1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a08c15d5c535bec0e3ec7f7331e16fdbfd6eebb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 08:52:30 +0000 Subject: [PATCH 052/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9269 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 9db8698..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T02:31:49.786Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2d7f70d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From eddd784110603ad9eb1c13fe9c96230af51901ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 04:06:10 +0000 Subject: [PATCH 053/146] Transform error messages --- lib/polyfill.js | 4 +++- package.json | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..ab32c37 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require( '@stdlib/error-tools-fmtprodmsg' ); + // TODO: write polyfill // MAIN // @@ -28,7 +30,7 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format( '01C00' ) ); } diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From df348c9d37a356c9cfa3ca9e7d43edd8ee636b88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 09:50:27 +0000 Subject: [PATCH 054/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2d7f70d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From db9420cefa98e035e987d010f6692a4a201696ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 09:51:27 +0000 Subject: [PATCH 055/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 39 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 92 files changed, 6211 insertions(+), 9269 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 b92586a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T02:42:24.650Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..edeef58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..834c747 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index ab32c37..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format( '01C00' ) ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0180c1c --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From dcb05127e2b294c6e09732336cfade6f70d0a446 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:57:18 +0000 Subject: [PATCH 056/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 3b0d1d1..c9b4b7e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8" + "@stdlib/assert-has-uint16array-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.0.7", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From de965c0286a6e3f43d13ad97519d6b93ef7b7ccf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 02:04:29 +0000 Subject: [PATCH 057/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 c6081c4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index edeef58..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("01C00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 834c747..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format( '01C00' ) );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAQ,SAC1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0180c1c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e258d4149dbd1aaca44e32931b459d3374d86701 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 02:05:26 +0000 Subject: [PATCH 058/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 94 files changed, 6211 insertions(+), 9281 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1469,7 +1462,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]. @@ -1533,23 +1526,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6286480 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fea18ad --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c9b4b7e..19fbcf3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-is-arraybuffer": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.0.7", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.0.7", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..98b39a4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 31a273348181a486f9cce051a274ec24a441d268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 02:47:20 +0000 Subject: [PATCH 059/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 982c8cf..e3aea28 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.0" + "@stdlib/assert-has-uint16array-support": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.0", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b75e3251b6858b6ae2fa16ec60bf7909866e1762 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 04:42:06 +0000 Subject: [PATCH 060/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6286480..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fea18ad..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;mMAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 98b39a4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0cde480339376890a8b5247985e3b9ef0d627e85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 04:43:05 +0000 Subject: [PATCH 061/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 95 files changed, 6211 insertions(+), 9316 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 ddbe561..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6c8cdca..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0904f4a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index e3aea28..390a148 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.0", - "@stdlib/assert-is-arraybuffer": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-uint16array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/math-base-special-round": "^0.1.0", - "@stdlib/random-base-randi": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/symbol-iterator": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9cf9eb1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 56a53274b411e55e88dc168f8df22bce338066fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 05:47:04 +0000 Subject: [PATCH 062/146] 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 4a634d7..3fa65f4 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.0-esm/index.mjs'; ``` #### Uint16Array() @@ -1414,7 +1414,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.0-esm/index.mjs'; var arr; var i; From ce9a0053aaee2c41d0249288c30b50e8a8be34e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 05:47:05 +0000 Subject: [PATCH 063/146] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fa65f4..742c830 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-uint16/tags). For example, + ```javascript import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.0-esm/index.mjs'; ``` @@ -1414,7 +1419,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.0-esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; var arr; var i; From 4b1eb9f51b6c99ca981dfe0189b6d86a960b91e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 04:59:46 +0000 Subject: [PATCH 064/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index ba3cdcb..dc457e4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.0" + "@stdlib/assert-has-uint16array-support": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.0", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6e34e5de173e09312860169f469256d5a876eb9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 05:06:13 +0000 Subject: [PATCH 065/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0904f4a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9cf9eb1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 343ffd1375eb417edbac1110560ed9f94086c811 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 05:09:20 +0000 Subject: [PATCH 066/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 80 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 6211 insertions(+), 9455 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5b6a9cc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T02:00:30.979Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0904f4a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index dc457e4..390a148 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.0", - "@stdlib/assert-is-arraybuffer": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.0", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1e7453e --- /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 31638e7..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../../dist/polyfill.js' ); -var ctor = require( './../../dist' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../dist', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../dist', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 9ce10298cfa1d3b78e59499e71347c28868f49aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 07:12:24 +0000 Subject: [PATCH 067/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 6ece007..b0622c1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2c85062a7d4c91ba0c50360e0e964651820bddc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 06:52:20 +0000 Subject: [PATCH 068/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0904f4a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1e7453e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 69cba7c6ae66ecb2f71d7f8c283fd38be74c8eab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 06:55:19 +0000 Subject: [PATCH 069/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 96 files changed, 6211 insertions(+), 9407 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4c559f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index b0622c1..390a148 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1617383 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From ca8b9d41fbe447bba485eb13fa3e543dddd4141a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Oct 2023 20:28:43 +0000 Subject: [PATCH 070/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 26ccf45..6eea678 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4dc4b38f5611952cef2db38e9f461c3fa222a5b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 00:46:51 +0000 Subject: [PATCH 071/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c559f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1617383..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ca2a3b0a7490decc457044f1f1533c78a298b8ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 00:50:09 +0000 Subject: [PATCH 072/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 37 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 96 files changed, 6211 insertions(+), 9406 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..be5fcd9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..032be5a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 0d55e2b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 6eea678..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..64f5429 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 7f64bd2ea3723d57e76b0e158390f59d95ca3549 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 03:43:06 +0000 Subject: [PATCH 073/146] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ca911f..cb61da1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.1-esm/index.mjs'; ``` #### Uint16Array() @@ -1414,7 +1414,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.1-esm/index.mjs'; var arr; var i; From f62a5960d53f869f9dde2df3a460d8629477e187 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 10 Oct 2023 03:43:06 +0000 Subject: [PATCH 074/146] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cb61da1..10428d3 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-uint16/tags). For example, + ```javascript import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.1-esm/index.mjs'; ``` @@ -1414,7 +1419,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.1.1-esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; var arr; var i; From e4eb800aed5027de5fb466413dba71bb34ad567a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 05:07:40 +0000 Subject: [PATCH 075/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 26ccf45..6eea678 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3b64e8cb1871bc4628727aaa5c7e2f636fa25dc8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 05:26:32 +0000 Subject: [PATCH 076/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index be5fcd9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 032be5a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 64f5429..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3bbbc565f85b2f89a6fa39406757c66d6b977c44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 05:29:30 +0000 Subject: [PATCH 077/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 37 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 6211 insertions(+), 9416 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c1954ac..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T02:03:35.388Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5389938..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..456aade --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..77470a4 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 6eea678..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7e8fa3d --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 459e69eeb798f3ebeb3aa12ef66fd9aa4e1fc03d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:29:22 +0000 Subject: [PATCH 078/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index db08245..80bdf1c 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 182f050ab3ec5cb7465dbd96aa8218854d115ab8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:45:37 +0000 Subject: [PATCH 079/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 456aade..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 77470a4..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;4LAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7e8fa3d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8915dc29d5bce90cd5325b1a987e35b4e6bc54de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:48:21 +0000 Subject: [PATCH 080/146] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 96 files changed, 6211 insertions(+), 9414 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4c559f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 80bdf1c..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..84251b0 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 92e7493b290b40719ad98e26e3a72f1428c65a25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 24 Nov 2023 21:00:35 +0000 Subject: [PATCH 081/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 743578d..7889ad5 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 00c8af8a04094ccb9734f4db245313705573b606 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 24 Nov 2023 21:04:06 +0000 Subject: [PATCH 082/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c559f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 84251b0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5468e0098428747d29b97b17261512d6f0081354 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 24 Nov 2023 21:06:33 +0000 Subject: [PATCH 083/146] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 96 files changed, 6211 insertions(+), 9409 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4c559f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 7889ad5..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7bd57f6 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 34dd9338f6376379f4120b4b63e4bb86970789f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 04:31:46 +0000 Subject: [PATCH 084/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..dc73cdf 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00,Cw') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 743578d..7889ad5 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From dc82372eff3aa0ae286e28c9f6a8f8423d03f2bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 20:07:50 +0000 Subject: [PATCH 085/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c559f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7bd57f6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6629bab4c896d6158ccd1ce173ea47978a46591b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 20:10:22 +0000 Subject: [PATCH 086/146] 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 | 59 +- benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 6211 insertions(+), 9410 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fcf5637..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T02:11:21.750Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 781bdf1..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c3..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 0a24d7f..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c5..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 4b96831..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index b4434bc..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index dd50c29..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 87d524b..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 1deb6a5..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e4..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 25e31ac..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e8661..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5e467b8..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ced3f42..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index e23cff5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c7d6c7e..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index ee82533..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e86..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 209031f..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index bc8234c..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index eeee6da..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78697f2..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584a..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e133149..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5953fa3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 5605031..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index e525c65..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3564fec..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index aa1ac8b..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7d85c8a..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index d199718..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 9298af8..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index a948f47..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea3..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index d467184..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index ce798a1..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 765da2e..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 5142d7d..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 05a1fe8..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index ea4e6de..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 097166e..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 46f42ff..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 5fd6cf9..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc45..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0242aa2..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b5..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3e66512..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4c559f1 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8d49997 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index dc73cdf..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00,Cw') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 7889ad5..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..92b0fc9 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 57ce8835a0826ac4e6ae940dec0340297ef64524 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 03:08:32 +0000 Subject: [PATCH 087/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c094703..55f86dc 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 30ba6fc3256c2f31cb6ce457adde79115d8f07c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 07:53:46 +0000 Subject: [PATCH 088/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c559f1..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00,Cw"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8d49997..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00,Cw') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,YACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 92b0fc9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7ca9813102b7b11e31bbfa4f480a30d9181b5885 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 07:54:12 +0000 Subject: [PATCH 089/146] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 37 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 6211 insertions(+), 9415 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fdeaf98..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T01:55:12.780Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 808906c..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1480,7 +1473,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]. @@ -1544,23 +1537,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0d2f09a..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[esm-url]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..800772b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..032be5a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 0d55e2b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 55f86dc..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..331d663 --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 28ccc6a8dee6297cc66666394a047e20f4512693 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 03:17:36 +0000 Subject: [PATCH 090/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c094703..55f86dc 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1" + "@stdlib/assert-has-uint16array-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.1.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0516f586a0e7677d0b3b34ce06761c62079daff3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 07:08:35 +0000 Subject: [PATCH 091/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 800772b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 032be5a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 331d663..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3b86c77d54e51c458d3b75adae1dbaed99b06165 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 07:09:00 +0000 Subject: [PATCH 092/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 37 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 6211 insertions(+), 9420 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1598b67..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T02:14:13.128Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 808906c..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..800772b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..032be5a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 0d55e2b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 55f86dc..f08db37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-is-arraybuffer": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..20cbe4f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 9b68fe09a596e9e98b136bc26f2b81c6ce1c3f07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 06:42:53 +0000 Subject: [PATCH 093/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ccd19af..5e1184d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.0" + "@stdlib/assert-has-uint16array-support": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.0", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 675850c8ae97360aba8b7cd01f4dd7b54b806b91 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 12:55:06 +0000 Subject: [PATCH 094/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 800772b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.1.1-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 032be5a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 20cbe4f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3405662cd0e491382bd74e2df222be88f4213ef7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 12:55:31 +0000 Subject: [PATCH 095/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 --- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 37 - package.json | 66 +- stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 - test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 6211 insertions(+), 9423 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 c559180..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5ef4afc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.0-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..032be5a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 0d55e2b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 5e1184d..d48474f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.0", - "@stdlib/assert-is-arraybuffer": "^0.2.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/math-base-special-round": "^0.1.1", - "@stdlib/random-base-randi": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/symbol-iterator": "^0.2.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ac729cb --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From cff8dcb7919049a0e860c2ab3740d9d1ae4ceb4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:59:22 +0000 Subject: [PATCH 096/146] 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 5c1f407..eab4a26 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.0-esm/index.mjs'; ``` #### Uint16Array() @@ -1414,7 +1414,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.0-esm/index.mjs'; var arr; var i; From 79cfab4ea51c115e02b5ba8268fbf0dbcdaae941 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:59:22 +0000 Subject: [PATCH 097/146] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eab4a26..97d3fb6 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-uint16/tags). For example, + ```javascript import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.0-esm/index.mjs'; ``` @@ -1414,7 +1419,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.0-esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; var arr; var i; From 1400ef55a7a457ec7b74a55e8d220cf50ffb671f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 21:32:30 +0000 Subject: [PATCH 098/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index aeefd34..08ad951 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1" + "@stdlib/assert-has-uint16array-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5a8228e2a28fbe878d1bfa09ed7d504d1861e8b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:33:09 +0000 Subject: [PATCH 099/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6208 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5ef4afc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.0-esm/index.mjs";var t="function"==typeof Uint16Array?Uint16Array:void 0;var n=r()?t:function(){throw new Error("not implemented")};export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 032be5a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error"],"mappings":";;yGAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECdR,WACC,MAAM,IAAIC,MAAO,kBAClB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ac729cb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8249ba4907b1f0884005b762d3f9c6aa4952fa9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:34:32 +0000 Subject: [PATCH 100/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 4876 insertions(+), 9418 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..84ac272 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 08ad951..5e065d5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.0", - "@stdlib/symbol-iterator": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59855fc --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 1422e3cd3fa0defd874b3c3bd6bacb772a3a22fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:46:37 +0000 Subject: [PATCH 101/146] 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 cd0aa29..fff7b9c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.1-esm/index.mjs'; ``` #### Uint16Array() @@ -1414,7 +1414,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.1-esm/index.mjs'; var arr; var i; From eeb38f311c68dcea72261ba9c31e7ac63eaeddc7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 22:46:37 +0000 Subject: [PATCH 102/146] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fff7b9c..8f10cf0 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-uint16/tags). For example, + ```javascript import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.1-esm/index.mjs'; ``` @@ -1414,7 +1419,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.1-esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; var arr; var i; From 012e294b36a898939c5e954ceb86cd0b23768ecb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 03:01:17 +0000 Subject: [PATCH 103/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index b20ebf8..38eadf2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1" + "@stdlib/assert-has-uint16array-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 055a6b22b8b9349b03512609fd7eb33e7f8bc46c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 05:49:38 +0000 Subject: [PATCH 104/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 84ac272..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59855fc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d8762dfe235930f4c5d850c63599851114eb487 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 05:49:56 +0000 Subject: [PATCH 105/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9420 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d75f84c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T02:11:40.284Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..84ac272 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 38eadf2..5e065d5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59855fc --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 42501c2cc6b795d18eb75ee14d8850f17ca5d5d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 02:44:51 +0000 Subject: [PATCH 106/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index b20ebf8..38eadf2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1" + "@stdlib/assert-has-uint16array-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2c72b56daac7ab8b0920f6d7b9aeb76d7f94a2d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 06:11:03 +0000 Subject: [PATCH 107/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 84ac272..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59855fc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 86d0cfbfa7f5784dfa43aba886787bbbfac5a706 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 06:11:20 +0000 Subject: [PATCH 108/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9423 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index cef62e1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T01:51:26.898Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..84ac272 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 38eadf2..5e065d5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59855fc --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From d5bc8e9e061f5d9d066f59da2f663b7e4dc8b5c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 22:48:49 +0000 Subject: [PATCH 109/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index b20ebf8..38eadf2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1" + "@stdlib/assert-has-uint16array-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d11c8676f022ddb74c22a41af0da90ef579328f8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 02:29:57 +0000 Subject: [PATCH 110/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 84ac272..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59855fc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ba8f4a67e6776e3d3599c4a2b2f47a34a2eb7309 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 02:30:15 +0000 Subject: [PATCH 111/146] 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 | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 4876 insertions(+), 9424 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 43984e5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ); - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 1 - > arr2[ 1 ] - 2 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..84ac272 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 38eadf2..5e065d5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59855fc --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From cca22c0f42b09fa0b07152c0b1133b8b9659e03a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 05:47:54 +0000 Subject: [PATCH 112/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index b20ebf8..38eadf2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1" + "@stdlib/assert-has-uint16array-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.1", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c491099f6d7c1a286183eb288bcc96289efc3d0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 05:52:27 +0000 Subject: [PATCH 113/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 84ac272..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59855fc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dab18e69bfbb0b1aa926e4cdf264dd61c095e64b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 05:52:43 +0000 Subject: [PATCH 114/146] 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 | 248 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 4876 insertions(+), 9431 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..84ac272 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 38eadf2..5e065d5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-is-arraybuffer": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59855fc --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 65ec73935e2b6045f9012e620f08068fc0905ed0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:12:35 +0000 Subject: [PATCH 115/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 38f1e21..3ffa15e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7279c04754c96eee5b12cdeccea5de2961c953af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:33:47 +0000 Subject: [PATCH 116/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 84ac272..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59855fc..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dc1c0f36751e0f4f000e84356464953177dd60d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:34:06 +0000 Subject: [PATCH 117/146] 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 | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 97 files changed, 4876 insertions(+), 9641 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index 3ffa15e..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/math-base-special-round": "^0.2.1", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 3d2eeeb8dca42bba5c43cc2012dcd7bf0e253e70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:44:19 +0000 Subject: [PATCH 118/146] 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 38111aa..648c857 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.2-esm/index.mjs'; ``` #### Uint16Array() @@ -1414,7 +1414,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.2-esm/index.mjs'; var arr; var i; From 8f8d39a7e924e6669f3b3f8650e4b84308600e70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 14:44:20 +0000 Subject: [PATCH 119/146] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 648c857..d721c40 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-uint16/tags). For example, + ```javascript import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.2-esm/index.mjs'; ``` @@ -1414,7 +1419,7 @@ var bool = it.next().done; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@esm/index.mjs'; -import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.2-esm/index.mjs'; +import ctor from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; var arr; var i; From cb31589b50f52b72f9f44d990c369dd8c2cff6a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 03:11:46 +0000 Subject: [PATCH 120/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 74dddbf4157b3091e88dcfcccd552e76f47c6ec7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 06:13:23 +0000 Subject: [PATCH 121/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f30704a9bb59ac96acea95cae45323c98b5ec62b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 06:13:45 +0000 Subject: [PATCH 122/146] 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 | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9581 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9a97722..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T02:15:42.304Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From aff17c0d3329828633111e6db9a8cd84d08639f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:50:14 +0000 Subject: [PATCH 123/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5a94579f7d06a500583995465a1611c3e1242eec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:50:01 +0000 Subject: [PATCH 124/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d44ab3c8c030aba9928824c1e4ff218dcfec1b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:50:20 +0000 Subject: [PATCH 125/146] 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 | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9644 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d1733a7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T17:11:39.099Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 02b80c73ffc3c712702e4a5b3ad1ff8584a42b5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:18:44 +0000 Subject: [PATCH 126/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0de7951852cda153342cbf78ae91e574d915d32f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 06:01:44 +0000 Subject: [PATCH 127/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d2c4674f8f890cd79b739c79ea289ccdd81598d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 06:01:57 +0000 Subject: [PATCH 128/146] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9643 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c9e0f18..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T02:24:37.261Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 29d63ba8aeed7661f9582a6dad5e11b58b093fb9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:23:57 +0000 Subject: [PATCH 129/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 428d6c4bec7d5b2b9238b4af59700930d1db8dc4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 06:09:57 +0000 Subject: [PATCH 130/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e91b5eab5827a39a81cfd4b46bfea441626884a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 06:10:16 +0000 Subject: [PATCH 131/146] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9643 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d4300d5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T02:33:17.336Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From b86a41d29e1a27e3af4a9eb4f4dbd7cea87a4e35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:22:22 +0000 Subject: [PATCH 132/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c0256701d6f58f0db53558fdc3e6469b1fe0de15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 05:41:40 +0000 Subject: [PATCH 133/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b921fce2503e6d89f36129f45158698f9f25716f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 05:41:52 +0000 Subject: [PATCH 134/146] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9643 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ee9f63a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T02:33:01.669Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 30a3802a1d5314ce45874afc36827d15fd9999e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:28:51 +0000 Subject: [PATCH 135/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4b5799ff6b2f9df0776c7055f48403c99615937b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 06:11:07 +0000 Subject: [PATCH 136/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 77e0e7425f2df5387d153a361193474eb2fda4ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 06:11:25 +0000 Subject: [PATCH 137/146] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 99 files changed, 4876 insertions(+), 9748 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 00f6034..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T02:39:28.526Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 789bddafeb2a53a81f9a0c612ff7afc12a8b189d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:43:06 +0000 Subject: [PATCH 138/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ff7d63d684643d3ccc5393fc885030d42180b236 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:51:49 +0000 Subject: [PATCH 139/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d7717e71c229378d026417f9848824af12af481 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:52:08 +0000 Subject: [PATCH 140/146] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 99 files changed, 4876 insertions(+), 9748 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 5ade181..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T01:39:49.498Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..51059e7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 38a19dc72d021da53399389a357f5d94a6520bc0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 4 Jan 2025 21:20:13 +0000 Subject: [PATCH 141/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c832dd859c3522e516e27cb9d58697d463da5d81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 4 Jan 2025 21:22:40 +0000 Subject: [PATCH 142/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51059e7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 330a80c29ce44631ea38f8fd841b5ea429d7e7cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 4 Jan 2025 21:22:57 +0000 Subject: [PATCH 143/146] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 244 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 98 files changed, 4876 insertions(+), 9781 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5233531..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c8010db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests From 9ba9f62721aec56fc75ed44f5b7ce113383b8e87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:16:14 +0000 Subject: [PATCH 144/146] Transform error messages --- lib/polyfill.js | 5 +++-- package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/polyfill.js b/lib/polyfill.js index 0d55e2b..023535b 100644 --- a/lib/polyfill.js +++ b/lib/polyfill.js @@ -18,6 +18,8 @@ 'use strict'; +var format = require('@stdlib/error-tools-fmtprodmsg'); + // TODO: write polyfill // MAIN // @@ -28,10 +30,9 @@ * @throws {Error} not implemented */ function polyfill() { - throw new Error( 'not implemented' ); + throw new Error( format('02P00') ); } - // EXPORTS // module.exports = polyfill; diff --git a/package.json b/package.json index 87a204b..c3e87e0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2" + "@stdlib/assert-has-uint16array-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-has-property": "^0.2.2", @@ -95,4 +96,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3b3bcea766c8d5b13244c94eb2f6c01677fe81e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:47:23 +0000 Subject: [PATCH 145/146] Remove files --- index.d.ts | 26 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4873 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 fe62b61..0000000 --- a/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c8010db..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6d36170..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7ccb07f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2892f5818f5edfa12e8a2ba61d5e9fcc712ec777 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 01:47:37 +0000 Subject: [PATCH 146/146] 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 | 244 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.data.js | 75 - benchmark/benchmark.entries.js | 50 - benchmark/benchmark.every.js | 81 - benchmark/benchmark.every.length.js | 105 - benchmark/benchmark.fill.js | 51 - benchmark/benchmark.fill.length.js | 94 - benchmark/benchmark.filter.js | 81 - benchmark/benchmark.filter.length.js | 105 - benchmark/benchmark.find.js | 82 - benchmark/benchmark.find.length.js | 105 - benchmark/benchmark.find_index.js | 82 - benchmark/benchmark.find_index.length.js | 104 - benchmark/benchmark.for_each.js | 88 - benchmark/benchmark.for_each.length.js | 106 - benchmark/benchmark.from.js | 237 - benchmark/benchmark.includes.js | 53 - benchmark/benchmark.includes.length.js | 96 - benchmark/benchmark.index_of.js | 53 - benchmark/benchmark.index_of.length.js | 95 - benchmark/benchmark.join.js | 51 - benchmark/benchmark.join.length.js | 94 - benchmark/benchmark.js | 47 - benchmark/benchmark.keys.js | 50 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 81 - benchmark/benchmark.map.length.js | 105 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.properties.js | 145 - benchmark/benchmark.reduce.js | 80 - benchmark/benchmark.reduce.length.js | 105 - benchmark/benchmark.reduce_right.js | 80 - benchmark/benchmark.reduce_right.length.js | 105 - benchmark/benchmark.reverse.js | 52 - benchmark/benchmark.reverse.length.js | 95 - benchmark/benchmark.set.js | 94 - benchmark/benchmark.set.length.js | 114 - benchmark/benchmark.slice.js | 52 - benchmark/benchmark.slice.length.js | 95 - benchmark/benchmark.some.js | 81 - benchmark/benchmark.some.length.js | 105 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 105 - benchmark/benchmark.subarray.js | 51 - benchmark/benchmark.subarray.length.js | 94 - benchmark/benchmark.to_locale_string.js | 51 - .../benchmark.to_locale_string.length.js | 94 - benchmark/benchmark.to_string.js | 51 - benchmark/benchmark.to_string.length.js | 94 - benchmark/benchmark.values.js | 50 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 953 ---- docs/types/test.ts | 36 - examples/index.js | 32 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 52 - lib/main.js | 28 - lib/polyfill.js | 38 - package.json | 66 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.copy_within.js | 320 -- test/test.js | 80 - test/test.polyfill.js | 44 - 99 files changed, 4876 insertions(+), 9785 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.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.data.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.properties.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1429b9d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:08:36.796Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 60f3293..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/array/uint16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 77f2206..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/array/uint16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0d355a6..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: '12 0 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1482,7 +1473,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]. @@ -1549,23 +1540,23 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/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.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 604ff13..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 2e7f122..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.data.js b/benchmark/benchmark.data.js deleted file mode 100644 index 80154b7..0000000 --- a/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 2a80461..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index 975fd0f..0000000 --- a/benchmark/benchmark.every.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index bfc9da2..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 84f2b56..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 4692b24..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 8878f7d..0000000 --- a/benchmark/benchmark.filter.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index b252e8d..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index a92a16c..0000000 --- a/benchmark/benchmark.find.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index a4beef7..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 02e5de8..0000000 --- a/benchmark/benchmark.find_index.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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index e4d6993..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index fdfc37e..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 551d3dd..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 656b92f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index 67187e0..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index aea0054..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index bb8ff94..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 104d017..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index d2dbef6..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 5d8fd46..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 78210d7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dbb5ca7..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index d0fc4b1..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e6efa87..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 865854e..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 214bb9d..0000000 --- a/benchmark/benchmark.map.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 bench = require( '@stdlib/bench-harness' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index cb610c5..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index a9b4b5e..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.properties.js b/benchmark/benchmark.properties.js deleted file mode 100644 index 6590228..0000000 --- a/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 78119a4..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 4938746..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5af03c1..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 7bc762f..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 109a0df..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9773c68..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 0d0bfc9..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 38e3236..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 7bb37cd..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index d65da6c..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index c75f262..0000000 --- a/benchmark/benchmark.some.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 bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 74af52a..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 7156aa5..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index f19c114..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randi = require( '@stdlib/random-base-randi' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 2b1d99e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 88fbf44..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 1f57daa..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 7079cb5..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 21d1129..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1d0e55b..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2ae63d7..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 15d4506..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/array/uint16" -%% click B href "https://github.com/stdlib-js/array-uint16/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint16/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint16 -[production-url]: https://github.com/stdlib-js/array-uint16/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint16/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 c899cfe..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Uint16Array from '../docs/types/index'; -export = Uint16Array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf6a005..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var e=function(u,r){return function(){return r||u((r={exports:{}}).exports,r),r.exports}};var o=e(function(y,i){"use strict";var a=typeof Uint16Array=="function"?Uint16Array:void 0;i.exports=a});var s=e(function(q,n){"use strict";function l(){throw new Error("not implemented")}n.exports=l});var p=require("@stdlib/assert-has-uint16array-support"),c=o(),f=s(),t;p()?t=c:t=f;module.exports=t; -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 3a98e84..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = polyfill;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* var ctor = require( '@stdlib/array-uint16' );\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nvar hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,OAAO,aAAgB,WAAe,YAAc,OAKjED,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,GAAW,CACnB,MAAM,IAAI,MAAO,iBAAkB,CACpC,CAKAD,EAAO,QAAUC,ICFjB,IAAIC,EAAwB,QAAS,wCAAyC,EAC1EC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAsB,EAC1BG,EAAOF,EAEPE,EAAOD,EAMR,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "ctor", "require_polyfill", "__commonJSMin", "exports", "module", "polyfill", "hasUint16ArraySupport", "builtin", "polyfill", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26658c3..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d6ec15e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3dfeb21..0000000 --- a/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random-base-randu' ); -var round = require( '@stdlib/math-base-special-round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c8010db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-uint16array-support@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var s="function"==typeof Uint16Array?Uint16Array:void 0;var o=r()?s:function(){throw new Error(t("02P00"))};export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6d36170 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array-uint16\n*\n* @example\n* import ctor from '@stdlib/array-uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert-has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( format('02P00') );\n}\n\n// EXPORTS //\n\nexport default polyfill;\n"],"names":["ctor","Uint16Array","ctor$1","hasUint16ArraySupport","builtin","Error","format"],"mappings":";;0MAsBA,IAAIA,EAAgC,mBAAhBC,YAA+BA,iBAAc,EC6BjE,IAAAC,EATKC,IACGC,ECZR,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a8fbb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array-uint16 -* -* @example -* var ctor = require( '@stdlib/array-uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c6c4bcd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 023535b..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 format = require('@stdlib/error-tools-fmtprodmsg'); - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( format('02P00') ); -} - -// EXPORTS // - -module.exports = polyfill; diff --git a/package.json b/package.json index c3e87e0..c545958 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Uint16Array.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-uint16array-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-round": "^0.3.0", - "@stdlib/random-base-randi": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/symbol-iterator": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,4 +36,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7ccb07f --- /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.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 221d022..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index f6be54c..0000000 --- a/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert-has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 9d6fcb1..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests